package org.opens.sql;

/**
 * 生成代码模板
 * - 使用了模板设计模式
 */
public abstract class GenSqlTemplate<T> {

    protected void before(T t) {
        // pass
    }

    protected void after(T t) {
        // pass
    }

    protected void process(T t) {
        // pass
    }

    protected void afterThrowing(Exception e, T t) {
        // pass
    }

    protected void around(T t) {
        // pass
    }

    protected void afterReturning(T t) {
        // pass
    }

    public final void start(T t) {
        try {
            before(t);
            around(t);
            process(t);
            around(t);
            after(t);
        } catch (Exception e) {
            // pass
            afterThrowing(e, t);
        }
        afterReturning(t);
    }

}
